﻿@{
    ViewBag.Title = "Home";
}

<h1>Sample Saml2 Authentication Application</h1>
<p>
    This is a sample MVC application for Saml2 authentication.
</p>

@if (!User.Identity.IsAuthenticated)
{
    <p>
        You are currently <span id="status">not signed in</span>.
    </p>
    <p>
        <a href="@Url.Content("~/Saml2/SignIn")">Sign in</a> - default IDP
        @foreach (var idp in Sustainsys.Saml2.Configuration.SustainsysSaml2Section.Current.IdentityProviders)
        {
            var entityId = idp.EntityId;
            var destinationUrl = idp.SignOnUrl;
            <br />
            <a href="@Url.Content("~/Saml2/SignIn?idp=" + HttpUtility.UrlEncode(entityId))">Sign in</a>@: - @entityId - @destinationUrl
        }
    </p>
}
else
{
    <p>
        You are signed in. <a id="logout" href="@Url.Content("~/Saml2/Logout?ReturnUrl=" + Uri.EscapeDataString(Url.Content("~/?Status=LoggedOut")))">Logout</a>.
    </p>
    <table>
        <thead>
            <tr>
                <th>Claim Type</th>
                <th>Claim Value</th>
                <th>Issuer</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var c in System.Security.Claims.ClaimsPrincipal.Current.Claims)
            {
                <tr>
                    <td>@c.Type</td>
                    <td>@c.Value</td>
                    <td>@c.Issuer</td>
                </tr>                
            }
        </tbody>
    </table>
}

<p>
<a href="@Url.Content("~/Saml2/")">Service Provider Metadata.</a>
</p>
